//
//  HTVestTabBar.swift
//  MagaCore
//
//  Created by MrMessy on 2023/5/25.
//

import SwiftUI

struct HTVestTabBar: View {

  var var_onSubmit: ((String) -> Void)?
  @State var var_selectIndex: Int = 0

  var body: some View {
    NavigationView {
      TabView(selection: $var_selectIndex) {
        HTVestScreen1(var_onSubmit: var_onSubmit).tabItem {
          Text("Mix")
        }.tag(0)
        HTVestScreen2().tabItem {
          Text("Modify")
        }.tag(1)
        HTVestScreen3().tabItem {
          Text("Setting")
        }.tag(1)
      }
      .accentColor(Color(hex: "#FF6C3C"))
    }
    .navigationViewStyle(.stack)
  }
}

struct HTVestScreen1: View {

  var var_onSubmit: ((String) -> Void)?
  @State var var_text: String = ""

  var body: some View {
    VStack{
      HStack{
        TextField("Search", text: $var_text, onCommit: {
          var_onSubmit!(var_text)
        })
          .padding(.horizontal, 35)
          .frame(maxWidth: .infinity, maxHeight: 40)
          .font(.system(size: 12))
          .foregroundColor(Color(hex: "#393939"))
          .overlay(
            Image(systemName: "magnifyingglass")
              .foregroundColor(.gray)
              .frame(minWidth: 0, maxWidth: .infinity, alignment: .leading).padding(.leading, 10)
          )
          .background(Color.white)
          .clipShape(Capsule())
      }
      .padding(.top, 15)
      .padding(.horizontal, 15)
      .frame(maxWidth: .infinity)
      Spacer()
    }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
    .background(Color(hex: "#f2f2f2"))
    .navigationBarHidden(true)
  }
}

struct HTVestScreen2: View {
  var body: some View {
    VStack{}
      .frame(maxWidth: .infinity, maxHeight: .infinity)
      .background(Color(hex: "#f2f2f2"))
  }
}

struct HTVestScreen3: View {
  var body: some View {
    VStack{}
      .frame(maxWidth: .infinity, maxHeight: .infinity)
      .background(Color(hex: "#f2f2f2"))
  }
}
